gray code
A binary sequence used to convert the angular
position of a disk to digital form. Gray code has the
property that only one bit changes between any two positions
(the two positions' codes have a {Hamming distance} of one).
A radial line of sensors reads the code off the surface of the
disk and if the disk is half-way between two positions each
sensor might read its bit from both positions at once but
since only one bit differs between the two, the value read is
guaranteed to be one of the two valid values rather than some
third (invalid) combination (a {glitch}).
One possible {algorithm} for generating a gray code sequence
is to toggle bits in the order 0, 1, 0, 2, 0, 1, 0, 3, ...
This can also be stated as "toggle the lowest numbered bit
that results in a new code". Here is a four bit gray code
sequence generated in this way:
0 0 0 0
0 0 0 1
0 0 1 1
0 0 1 0
0 1 1 0
0 1 1 1
0 1 0 1
0 1 0 0
1 1 0 0
1 1 0 1
1 1 1 1
1 1 1 0
1 0 1 0
1 0 1 1
1 0 0 1
1 0 0 0
[Why "Gray"?]
(1994-11-09)